<div class="page-content">
    <div class="col-sm-6 pull-right">

        <button class="btn btn-sm btn-primary pull-right" onclick="javascript:window.location.href = '{:url("index")}'">
            返回列表
            <i class="icon-reply icon-only"></i>
        </button>
    </div>
    <div class="page-header">
        <h1>
            {:model('menu')->getParentNname()}
            <small>
                <i class="ace-icon fa fa-angle-double-right"></i>
                {:input('id')?'编辑':'新增'}
            </small>
        </h1>
    </div><!-- /.page-header -->

    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            <form class="form-horizontal" role="form" action="{:input('id')?url('edit'):url('add')}" method="post" name="myfrom" >
                {:input('id')?'<input type="hidden" value="'.$info['id'].'" name="id">':''}
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">集团</label>
                    <div class="col-sm-9">
                        <select name="com_id" style="width: 300px">
                            <option value="0" />请选择集团</option>
                            {foreach name="company" item="v"}
                            <option value="{$v.id}" {if condition="$v.id eq $info.com_id"}selected{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">样品编号</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.sampleno|default=''}" name="sampleno"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">断面id</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.section_id|default=''}" name="section_id"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">样品类型</label>
                    <div class="col-sm-9">

                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.sample_type|default=''}" name="sample_type"/>

                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">保存剂</label>
                    <div class="col-sm-9">
                        <textarea name="preservative_content" style="width: 520px;height: 100px;text-align: left">{$info.preservative_content|default=''}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">水系</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.basin|default=''}" name="basin"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">河名</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.rive_name|default=''}" name="rive_name"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">地址</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.address|default=''}" name="address"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">采样方法</label>
                    <div class="col-sm-9">
                        <select name="sampling_type" style="width: 300px">-->
                            <option value="0" />请选择采样方法</option>
                            {foreach name="samplingType" item="v" key='k'}
                            <option value="{$k}" {if condition="$k eq $info.sampling_type"}selected{/if}>{$v}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">测次编号</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.numberost|default=''}" name="numberost"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">水位</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.water_level|default=''}" name="water_level"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">流量</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.flow|default=''}" name="flow"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">水面宽度</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.width_water|default=''}" name="width_water"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">气温</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.air_temper|default=''}" name="air_temper"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">水深</label>
                    <div class="col-sm-9" style="line-height: 30px;height: 32px;">
                        <span style="float: left;margin-left: 20px;" >左</span> <input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.left_water_depth|default=''}" name="left_water_depth"/>&nbsp;
                        <span style="float: left;margin-left: 20px;">中</span><input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.middle_water_depth|default=''}" name="middle_water_depth"/>&nbsp;
                        <span style="float: left;margin-left: 20px;">右</span> <input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.right_water_depth|default=''}" name="right_water_depth"/>&nbsp;
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">水温</label>
                    <div class="col-sm-9" style="line-height: 30px;height: 32px;">
                        <span style="float: left;margin-left: 20px;" >左</span> <input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.left_water_temper|default=''}" name="left_water_temper"/>&nbsp;
                        <span style="float: left;margin-left: 20px;">中</span><input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.middle_water_temper|default=''}" name="middle_water_temper"/>&nbsp;
                        <span style="float: left;margin-left: 20px;">右</span> <input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.right_water_temper|default=''}" name="right_water_temper"/>&nbsp;
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">PH值</label>
                    <div class="col-sm-9" style="line-height: 30px;height: 32px;">
                        <span style="float: left;margin-left: 20px;" >左</span> <input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.left_water_ph|default=''}" name="left_water_ph"/>&nbsp;
                        <span style="float: left;margin-left: 20px;">中</span><input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.middle_water_ph|default=''}" name="middle_water_ph"/>&nbsp;
                        <span style="float: left;margin-left: 20px;">右</span> <input type="text" style="width: 100px;height:30px;margin-left:5px;" class="col-xs-10 col-sm-5" value="{$info.right_water_ph|default=''}" name="right_water_ph"/>&nbsp;
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">污染现象观察</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.pollution|default=''}" name="pollution"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">备注</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.remarks|default=''}" name="remarks"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">采样时间</label>
                    <div class="col-sm-9">
                        {if condition="$info['sample_time']"}
                        <input type="text" class="col-xs-10 col-sm-5" value="{:date('Y-m-d H:i:s',$info['sample_time'])}" name="sample_time"/>
                        {else /}
                        <input type="text" class="col-xs-10 col-sm-5" value="{:date('Y-m-d H:i:s')}" name="sample_time"/>
                        {/if}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">采样人（至少是2个人）</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.sample_person|default=''}" name="sample_person"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">详细地址</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.detailed_address|default=''}" name="detailed_address"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">现场照片(多个用;隔开)</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.pic|default=''}" name="pic"/>
                    </div>
                </div>


                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">状态</label>
                    <div class="col-sm-9" style="height: 32px;line-height: 36px">
                        <input type="radio"   name="status" value="1" {if condition="!isset($info['status']) || $info['status'] eq 1"}checked{/if}/> 已采样&nbsp;&nbsp;
                        <input type="radio"   name="status" value="2" {if condition="isset($info['status']) && $info['status'] eq 2"}checked{/if}/> 已收样
                        <input type="radio"   name="status" value="3" {if condition="isset($info['status']) && $info['status'] eq 3"}checked{/if}/> 已分配
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="button" onclick="myfrom.submit()">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            提交
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="ace-icon fa fa-undo bigger-110"></i>
                            重置
                        </button>
                    </div>
                </div>
            </form>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->

<script>

    function getRegion(data,strName){

        var parent_id = $(data).find("option:selected").attr('data-id');

        var url = "{:url('getRegion')}";

        $.post(url,{parent_id:parent_id},function(res){
            var data = $.parseJSON(res)
            if(strName == 'city'){
                var html = '<option value="" >请选择市</option>';
            }else{
                var html = '<option value="" >请选择区县</option>';
            }


            for(let key  in data){

                 html+="<option value='"+data[key].name+"'  data-id='"+data[key].id+"'>"+data[key].name+"</option>"
            }

            $("select[name='"+strName+"']").html(html);
        }, 'json')
    }


</script>